package com.caigou.modules.famous.adpter

import android.widget.CheckBox
import android.widget.CompoundButton
import com.caigou.comm.base.bean.PrizeBallBean
import com.caigou.modules.famous.R
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder

/**
 * @author #Suyghur.
 * Created on 2021/12/08
 */
class PublishBallItem2Adapter(dataset: MutableList<PrizeBallBean>, private val listener: CompoundButton.OnCheckedChangeListener) :
    BaseQuickAdapter<PrizeBallBean, BaseViewHolder>(R.layout.item_publish_ball2_list, dataset) {

    override fun convert(holder: BaseViewHolder, item: PrizeBallBean) {
        val checkBox = holder.getView<CheckBox>(R.id.item_publish_ball2_cb)
        when (item.color) {
            1 -> {
                checkBox.setBackgroundResource(R.drawable.comm_btn_red_selector_bg2)
                checkBox.setTextColor(context.resources.getColorStateList(R.color.comm_red_txt_selector_bg))
            }
            2 -> {
                checkBox.setBackgroundResource(R.drawable.comm_btn_blue_selector_bg)
                checkBox.setTextColor(context.resources.getColorStateList(R.color.comm_blue_txt_selector_bg))
            }
            3 -> {
                checkBox.setBackgroundResource(R.drawable.comm_btn_green_selector_bg)
                checkBox.setTextColor(context.resources.getColorStateList(R.color.comm_green_txt_selector_bg))
            }
        }
        checkBox.text = item.number
        checkBox.setOnCheckedChangeListener(listener)
    }
}